// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import ComponentBase from "./componentBase";
import Message from "./Message";

const {ccclass, property} = cc._decorator;


export default class MessageCenter {

    static Managers: ComponentBase[] = [];

    // 发送消息
    static SendMessage(message: Message) {
        console.log(this.Managers)
        for (let manager of this.Managers) {
            console.log(`消息中心广播消息`)
            manager.ReceiveMessage(message);
        }
    }

    static SendCustomMessage(type: number, command: number, content: any) {
        let message = new Message(type, command, content);
        console.log(`消息中心收到消息`)
        this.SendMessage(message)
    }
}
